package com.scsj.supermarket.view.activity.goodmodel;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.google.gson.Gson;
import com.scsj.supermarket.R;
import com.scsj.supermarket.adapter.AllGoodsCommentAdapter;
import com.scsj.supermarket.adapter.MineCommentAdapter;
import com.scsj.supermarket.base.AppCommodityEvaluationBase;
import com.scsj.supermarket.bean.AppCommodityEvaluationBean;
import com.scsj.supermarket.bean.SelectAppRankBean;
import com.scsj.supermarket.bean.parameter.AppCommodityEvaluationPostBean;
import com.scsj.supermarket.presenter.AppCommodityEvaluationPresenter;
import com.scsj.supermarket.view.activity.baseactivitymodel.BaseActivity;

import java.util.ArrayList;
import java.util.List;

import okhttp3.RequestBody;

/**
 * 我的评价（商品评价）    与  AllGoodsCommentActivity 类功能类似
 */
public class MineCommentActivity extends BaseActivity implements AppCommodityEvaluationBase.IView {

    private RecyclerView allGoodsCommentRv;
    private AllGoodsCommentAdapter allGoodsCommentAdapter;
    private AppCommodityEvaluationPresenter presenter;
    private String goodsId;
    private String storeId;


    @Override
    protected void createView(Bundle savedInstanceState) {
        setContentView(R.layout.activity_all_goods_comment);
        presenter = new AppCommodityEvaluationPresenter(this);
        initView();
        // TODO: 2018/7/5
        goodsId = getIntent().getStringExtra("goodsId");
        storeId = getIntent().getStringExtra("storeId");
        AppCommodityEvaluationPostBean postBean = new AppCommodityEvaluationPostBean();
        postBean.setGoodsEvaluationDetail(new AppCommodityEvaluationPostBean.GoodsEvaluationDetailBean(goodsId,storeId));
        String s = new Gson().toJson(postBean);
        RequestBody body = RequestBody.create(okhttp3.MediaType
                .parse("application/json;charset=utf-8"), s);
        presenter.deliverData(body);
        initToolbar();
        setToolbarTitle("商品评论");
        hasBack(true);
        initData();
        initListener();
    }

    @Override
    protected void initView() {
        allGoodsCommentRv = findViewById(R.id.comment_list_rv);
        allGoodsCommentRv.setNestedScrollingEnabled(false);

    }

    @Override
    protected void initListener() {

    }

    @Override
    protected void initData() {
        /**
         * 网络图片集合 http://img1.3lian.com/2015/w10/51/d/27.jpg
         * 测试用
         */
    }

    @Override
    public void showSuccessMsg(String s, AppCommodityEvaluationBean appCommodityEvaluationBean) {
        List<String> listImg = new ArrayList<>();
        listImg.add("http://img1.3lian.com/2015/w10/51/d/27.jpg");
        listImg.add("http://img1.3lian.com/2015/w10/51/d/27.jpg");
        listImg.add("http://img1.3lian.com/2015/w10/51/d/27.jpg");
        listImg.add("http://img1.3lian.com/2015/w10/51/d/27.jpg");
        listImg.add("http://img1.3lian.com/2015/w10/51/d/27.jpg");
        allGoodsCommentRv.setLayoutManager(new LinearLayoutManager(this));
        allGoodsCommentAdapter = new AllGoodsCommentAdapter(listImg, this);
        allGoodsCommentRv.setAdapter(allGoodsCommentAdapter);
    }

    @Override
    public void showSelectSuccessMsg(String s, SelectAppRankBean selectAppRankBean) {

    }

    @Override
    public void showErrorMsg(String s) {

    }
}
